----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/code/logs/table_A5_phi_vs_z_country.log
  log type:  text
 opened on:  30 Oct 2022, 22:12:22

. *-------------------------------------------------------------------------------
. 
. 
. 
. 
. *Aggregate economy 
. *-----------------------------------------------------------------
. clear all

. use "${data}/estimates_agg_naics_sales_s1_base_woparent.dta", clear

. 
. local grvar0 "gdp_pw_ppp" 

. local grvar1 "" 

. local rr ""

. local var3 "A"

. local yy "2016"

. local yy_ref=`yy'       

. replace year=`yy_ref'
(0 real changes made)

. merge m:1 year isocode type using "${data}/aggregates_tfp_lp_klems_agg.dta" 
(note: variable year was float, now double to accommodate using data's values)
(note: variable isocode was str2, now str32 to accommodate using data's values)
(note: variable type was str5, now str9 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                         2,985
        from master                         0  (_merge==1)
        from using                      2,985  (_merge==2)

    matched                                27  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(2,985 observations deleted)

. drop _merge

. 
. foreach var in D_A  {
  2. gen `var'_phi=(-1)*`var'*(0.2)
  3. *---------------------------------------
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. }

. 
. keep isocode D_A_phi ln_gdp_pw_ppp

. rename D_A_phi delta_phi_agg

. rename ln_gdp_pw_ppp delta_yn

. format %9.2fc delta_phi_agg delta_yn

. sort isocode

. 
. tempfile temp_agg

. save `temp_agg', replace 
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000t.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000t.tmp saved

.         
.         
.         
. 
. *Manufacturing and Services 
. *-----------------------------------------------------------------
. clear all

. use "${data}/estimates_aggtype_naics_sales_s1_base_woparent.dta", clear

. 
. local grvar0 "LP_ppp_emp_pwt" 

. local grvar1 "" 

. local rr ""

. local var3 "A"

. local yy "2016"

. local yy_ref=`yy'       

. replace year=`yy_ref'
(0 real changes made)

. merge m:1 year isocode type using "${data}/aggregates_tfp_lp_klems_agg.dta" 
(note: variable year was float, now double to accommodate using data's values)
(note: variable isocode was str2, now str32 to accommodate using data's values)
(note: variable type was str6, now str9 to accommodate using data's values)

    Result                           # of obs.
    -----------------------------------------
    not matched                         2,931
        from master                         0  (_merge==1)
        from using                      2,931  (_merge==2)

    matched                                81  (_merge==3)
    -----------------------------------------

. drop if _merge==2
(2,931 observations deleted)

. drop _merge

. 
. foreach var in D_A  {
  2. gen `var'_phi=(-1)*`var'*(0.2)
  3. *---------------------------------------
. gen b_`var'_phi_`grvar0'=ln_`grvar0' - `var'_phi
  4. }
(1 missing value generated)
(1 missing value generated)

. 
. tempfile temp

. save `temp', replace
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000u.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000u.tmp saved

. 
. 
. *Manufacturing 
. *-------------------------------------------------------------------------------------
. use `temp', clear

. keep if type=="manuf"
(54 observations deleted)

. keep isocode D_A_phi 

. rename D_A_phi delta_phi_manuf

. format %9.2fc delta_phi_manuf 

. sort isocode

. 
. tempfile temp_manuf

. save `temp_manuf', replace 
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000v.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000v.tmp saved

. 
. 
. *Services 
. *-------------------------------------------------------------------------------------
. use `temp', clear

. keep if type=="serv"
(54 observations deleted)

. keep isocode D_A_phi 

. rename D_A_phi delta_phi_serv

. format %9.2fc delta_phi_serv 

. sort isocode

. 
. tempfile temp_serv

. save `temp_serv', replace 
(note: file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000w.tmp not found)
file C:\Users\VANESS~1\AppData\Local\Temp\ST_2d9c_00000w.tmp saved

. 
. 
. 
. 
. *Merging PHI's aggregate, manufacturing, and services 
. *-------------------------------------------------------------------------------------
. use `temp_agg', clear

. 
. merge m:1 isocode using `temp_manuf'

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                                27  (_merge==3)
    -----------------------------------------

. drop _merge

. 
. merge m:1 isocode using `temp_serv'

    Result                           # of obs.
    -----------------------------------------
    not matched                             0
    matched                                27  (_merge==3)
    -----------------------------------------

. drop _merge

. 
. export delimited using "${rappendix}/table_A5_phi_vs_z_country.csv", replace
(note: file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/table_A5_phi_vs_z_country.csv n
> ot found)
file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/table_A5_phi_vs_z_country.csv saved

. 
. 
. 
. 
end of do-file

. export delimited using "F:\Dropbox (UBC-Umich)\Research_Projects\Project Javier and Natalia\TFP firm\TFP_firm_data_historical\dataverse_files\results\appendix\table_A5_phi_vs_z
> _country.csv", datafmt replace
file F:\Dropbox (UBC-Umich)\Research_Projects\Project Javier and Natalia\TFP firm\TFP_firm_data_historical\dataverse_files\results\appendix\table_A5_phi_vs_z_country.csv is
    read-only; cannot be modified or erased
r(603);

. export delimited using "F:\Dropbox (UBC-Umich)\Research_Projects\Project Javier and Natalia\TFP firm\TFP_firm_data_historical\dataverse_files\results\appendix\table_A5_phi_vs_z
> _country.csv", datafmt replace
(note: file F:\Dropbox (UBC-Umich)\Research_Projects\Project Javier and Natalia\TFP firm\TFP_firm_data_historical\dataverse_files\results\appendix\table_A5_phi_vs_z_country.csv n
> ot found)
file F:\Dropbox (UBC-Umich)\Research_Projects\Project Javier and Natalia\TFP firm\TFP_firm_data_historical\dataverse_files\results\appendix\table_A5_phi_vs_z_country.csv saved

. local title "naics_sales_s1_base_woparent"

. 
. clear all

. 
. use "${data}/gravitycoef_`title'.dta", clear

. *-------------------------------------------------------------------------------

. 
. global typeden=1

. 
. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. . 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. 
. global lf "LF"

. 
. 
. 
. *Log

. 
. *cap log close

. 
. *log using "${clogs}/table_A1_gravity_coef.log",replace

. 
. *-------------------------------------------------------------------------------

. 
. 
. 
. 
. 
. local title "naics_sales_s1_base_woparent"

. 
. clear all

. 
. use "${data}/gravitycoef_`title'.dta", clear

. 
. keep sector coef_distance se_distance coef_language se_language

. 
. 
. 
. gen sector_order="NA"

. 
. 
. 
. *Other goods

. 
. *---------------------------------------

. 
. replace sector_order="1.1" if sector=="AgrMining (A-B)"
variable sector_order was str2 now str3
(1 real change made)

. 
. replace sector_order="1.2" if sector=="Electricity (D-E)"
(1 real change made)

. 
. replace sector_order="1.2" if sector=="Construction (F)"
(1 real change made)

. 
. 
. 
. *Manufacturing

. 
. *---------------------------------------

. 
. replace sector_order="2.1" if sector=="Food (10-12)"
(1 real change made)

. 
. replace sector_order="2.2" if sector=="TexWood (13-18)"
(1 real change made)

. 
. replace sector_order="2.3" if sector=="ChePetPla (19-23)"
(1 real change made)

. 
. replace sector_order="2.4" if sector=="Basic Metals (24-25)"
(1 real change made)

. 
. replace sector_order="2.5" if sector=="ElecMach (26-28)"
(1 real change made)

. 
. replace sector_order="2.6" if sector=="TranspOtherManuf (29-33)"
(1 real change made)

. 
. 
. 
. *Services

. 
. *---------------------------------------

. 
. replace sector_order="3.1" if sector=="Wholesale_Retail (G)"
(1 real change made)

. 
. replace sector_order="3.2" if sector=="Transportation_Storage (H)"
(1 real change made)

. 
. replace sector_order="3.3" if sector=="Information (J)"
(1 real change made)

. 
. replace sector_order="3.4" if sector=="Financial_Insurance (K)"
(1 real change made)

. 
. replace sector_order="3.5" if sector=="Support_Services (M-N)"
(1 real change made)

. 
. replace sector_order="3.6" if sector=="Accomod_Recreat (I-R-S)"
(1 real change made)

. 
. 
. 
. *Other sectors

. 
. *---------------------------------------

. 
. replace sector_order="4.1" if sector=="Education (P)"
(1 real change made)

. 
. replace sector_order="4.2" if sector=="Health (Q)"
(1 real change made)

. 
. replace sector_order="4.3" if sector=="Real_Estate (L)"
(1 real change made)

. 
. 
. 
. drop if sector=="Public_Administration (O)"
(1 observation deleted)

. 
. sort sector_order

. order sector_order sector

. br

. *-------------------------------------------------------------------------------

. 
. global typeden=1

. 
. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. . 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. 
. global lf "LF"

. 
. 
. 
. *Log

. 
. *cap log close

. 
. *log using "${clogs}/table_A1_gravity_coef.log",replace

. 
. *-------------------------------------------------------------------------------

. 
. 
. 
. 
. 
. local title "naics_sales_s1_base_woparent"

. 
. clear all

. 
. use "${data}/gravitycoef_`title'.dta", clear

. 
. keep sector coef_* se_*

. 
. 
. 
. gen sector_order="NA"

. 
. 
. 
. *Other goods

. 
. *---------------------------------------

. 
. replace sector_order="1.1" if sector=="AgrMining (A-B)"
variable sector_order was str2 now str3
(1 real change made)

. 
. replace sector_order="1.2" if sector=="Electricity (D-E)"
(1 real change made)

. 
. replace sector_order="1.2" if sector=="Construction (F)"
(1 real change made)

. 
. 
. 
. *Manufacturing

. 
. *---------------------------------------

. 
. replace sector_order="2.1" if sector=="Food (10-12)"
(1 real change made)

. 
. replace sector_order="2.2" if sector=="TexWood (13-18)"
(1 real change made)

. 
. replace sector_order="2.3" if sector=="ChePetPla (19-23)"
(1 real change made)

. 
. replace sector_order="2.4" if sector=="Basic Metals (24-25)"
(1 real change made)

. 
. replace sector_order="2.5" if sector=="ElecMach (26-28)"
(1 real change made)

. 
. replace sector_order="2.6" if sector=="TranspOtherManuf (29-33)"
(1 real change made)

. 
. 
. 
. *Services

. 
. *---------------------------------------

. 
. replace sector_order="3.1" if sector=="Wholesale_Retail (G)"
(1 real change made)

. 
. replace sector_order="3.2" if sector=="Transportation_Storage (H)"
(1 real change made)

. 
. replace sector_order="3.3" if sector=="Information (J)"
(1 real change made)

. 
. replace sector_order="3.4" if sector=="Financial_Insurance (K)"
(1 real change made)

. 
. replace sector_order="3.5" if sector=="Support_Services (M-N)"
(1 real change made)

. 
. replace sector_order="3.6" if sector=="Accomod_Recreat (I-R-S)"
(1 real change made)

. 
. 
. 
. *Other sectors

. 
. *---------------------------------------

. 
. replace sector_order="4.1" if sector=="Education (P)"
(1 real change made)

. 
. replace sector_order="4.2" if sector=="Health (Q)"
(1 real change made)

. 
. replace sector_order="4.3" if sector=="Real_Estate (L)"
(1 real change made)

. 
. 
. 
. drop if sector=="Public_Administration (O)"
(1 observation deleted)

. 
. sort sector_order

. 
. order sector_order sector

. 
. 
. 
. format %9.3fc coef_* se_*

. export delimited using "${rappendix}/table_A1_gravity_coef.csv", datafmt replace
(note: file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/table_A1_gravity_coef.csv not f
> ound)
file F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files/results/appendix/table_A1_gravity_coef.csv saved

. do "F:\Dropbox (UBC-Umich)\Research_Projects\Project Javier and Natalia\TFP firm\TFP_firm_data_historical\dataverse_files\code\appendix\table_A1_gravity_coef.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: table_A1_gravity_coef.do
> Date: October 2022
> 
> Description: Reproduces Table A.1: Estimates of gravity coeficients.
> 
> *****************************************************************************************/
. 
. *-------------------------------------------------------------------------------
. global typeden=1

. include "set_directories.do"

. /***************************************************************************************
> Firm-embedded productivity and cross-country income differences
> Alviarez, Cravino and Ramondo
> Journal of Political Economy (2022)
> 
> Program: set_directories.do
> Date: October 2022
> 
> Description: Sets directory paths
> *****************************************************************************************/
. 
. *Set root directory here
. global root "F:/Dropbox (UBC-Umich)/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical/dataverse_files" 

. 
. 
. *All other directories set automatically
. 
. *Code
. global code "${root}/code"

. global clogs "${root}/code/logs"

. global cmain "${root}/code/main"

. global cappendix "${root}/code/appendix"

. 
. *Data
. global data "${root}/data/analysis"

. global tmp  "${root}/data/tmp"

. 
. *Results
. global rmain "${root}/results/main"

. global rappendix  "${root}/results/appendix"

. 
. if $typeden==0 {
. local denominator "_exp_ko"
. }

. if $typeden==1 {
. local denominator "_ko"
. }

. *
. 
. 
. 
. /*******************************************************************************
> *Stata packages to install:
>    1) gtools
>    2) reghdfe
> *******************************************************************************/
. 
. 
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. *global maindirectory "F:/Dropbox (UBC-Umich)"
. *global maindirectory "C:\Users\cheoy\Dropbox (UBC-Umich)"
. *global tfp "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data_historical" 
. *global tfp_bef "${maindirectory}/Research_Projects/Project Javier and Natalia/TFP firm/TFP_firm_data" 
. *global orbis_historical "${maindirectory}/Master_Dataset/Orbis_master/Javier_Florian/orbis_data/final_data"
. ************** ESTO DE ACA ES LO QUE TENGO QUE BORRAR **************
. 
. *global inputs "${tfp}/data/inputs"
. *global code "${tfp}/code"
. *global output "${tfp}/data/output"
. *global results "${tfp}/results"
. 
. 
. 
. 
. 
. 
. 
. 
. set memory 64g
set memory ignored.
    Memory no longer needs to be set in modern Statas; memory adjustments are performed on the fly automatically.

. global lf "LF"

. 
. *Log
. cap log close
